package com.ptc.ims.client.view;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.ptc.ims.client.presenter.ProductPresenter.Display;

public class ProductCreateView 
extends Composite 
implements Display 
{
	private final Button addButton;
	private final Button cancelButton;
	private final TextBox productName;
	private final TextBox price;
	
	public ProductCreateView() 
	{
		DecoratorPanel mainPanelDecorator = new DecoratorPanel();
		mainPanelDecorator.addStyleName("main");
		initWidget(mainPanelDecorator);		
		mainPanelDecorator.setWidth("25em");
		
		FlexTable contentTable = new FlexTable();
		contentTable.setWidth("100%");
		contentTable.getCellFormatter().addStyleName(0, 0, "product");
		contentTable.getCellFormatter().setWidth(0, 0, "100%");
		contentTable.getFlexCellFormatter().setVerticalAlignment(0, 0, DockPanel.ALIGN_TOP);		
		
		productName = new TextBox();
		price = new TextBox();	
		contentTable.setWidget(0, 0, new Label("Name:"));
		contentTable.setWidget(0, 1, productName);
		contentTable.setWidget(1, 0, new Label("Price"));
		contentTable.setWidget(1, 1, price);
		
		HorizontalPanel buttonPanel = new HorizontalPanel();
		addButton = new Button("Add");
		cancelButton = new Button("Cancel");
		buttonPanel.add(cancelButton);
		buttonPanel.add(addButton);		
		buttonPanel.addStyleName("buttons");
		contentTable.setWidget(3, 1, buttonPanel);
		
		mainPanelDecorator.add(contentTable);
		
	}
	
	@Override
	public HasClickHandlers getAddUpdateButton()
	{		
		return addButton;
	}

	@Override
	public HasClickHandlers getCancelButton() 
	{		
		return cancelButton;
	}

	@Override
	public HasValue<String> getProductName()
	{		
		return productName;
	}

	@Override
	public HasValue<String> getPrice() 
	{		
		return price;
	}
	
	@Override
	public String getId()
	{		
		return null;
	}

}
